package org.loda.model;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public abstract class BaseModel {
	/**请求、响应都是利用map来设置和获取值*/
	protected Map<String, Object> map = new HashMap<String, Object>();

	public int size() {
		return map.size();
	}

	public boolean isEmpty() {
		return map.isEmpty();
	}

	public boolean containsKey(Object key) {
		return map.containsKey(key);
	}

	public boolean containsValue(Object value) {
		return map.containsValue(value);
	}

	public Object get(Object key) {
		return map.get(key);
	}

	public void clear() {
		map.clear();
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder("");
		for (Entry<String, Object> entry : map.entrySet()) {
			sb.append(entry.getKey() + ":" + entry.getValue() + ",");
		}
		if(sb.toString().endsWith(",")){
			sb.deleteCharAt(sb.length() - 1);
		}
		return sb.toString();
	}
}
